﻿using System.Linq;
using INSE6260.OnlineBanking.Infrastructure;
using INSE6260.OnlineBanking.Model.Clients;

namespace INSE6260.OnlineBanking.Repository.EF.Repositories
{
    public class ClientRepository : RepositoryBase<Client>, IClientRepository
    {
        public ClientRepository(IUnitOfWork unitOfWork)
            : base(unitOfWork)
        {

        }

        public Client GetFirstCustomerStartWith(string start)
        {
            return GetObjectSet().FirstOrDefault(customer => customer.FirstName.StartsWith(start));
        }


        public Client GetClientByClientId(int? clientId)
        {
            return GetObjectSet().FirstOrDefault(client => client.Id == clientId);
        }

        public void UpdateProfile(Client client)
        {
            Update(client);
            SaveChanges();
        }

        public Client FindClient(int clientId)
        {
            return FindByID(clientId);
        }

    }
}
